<template>
  <div class="content pt20">
    <div class="list-warp" v-if="postData?.businessProductRecommendList?.length > 0">
      <div v-for="item in postData?.businessProductRecommendList || []" :key="item.collectId" class="item" @click="toPath(item)">
        <div class="img_center">
          <img :src="item.mainPicUrl" :alt="item.title" class="picture" height="280px" />
        </div>
        <div class="img_message">
          <div class="img_message_title text-over" :title="item.productName || item.productAliasName">
            {{ item.productName || item.productAliasName }}
          </div>
          <div class="img_message_price">¥{{ item.businessLowestPrice }}</div>
        </div>
      </div>
    </div>
    <el-empty v-else description="这里暂时什么都没有"></el-empty>
  </div>
</template>
<script setup>
import { onMounted, ref, reactive } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  postData: {
    type: Object
  }
});
const toPath = item => {
  const routeUrl = router.resolve({
    path: "/shopDetail/index",
    query: {
      id: item.productId
    }
  });
  window.open(routeUrl.href, "_blank");
};
</script>

<style lang="scss" scoped>
.content {
  .list-warp {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 固定四列 */
    gap: 20px; /* 图片之间的间隙 */
    .item {
      break-inside: avoid; /* 防止元素内部分割，从而保持完整 */
      background-color: #fff;
      border-radius: 10px 10px 10px 10px;
      border: 1px solid #dcdfe6;
      overflow: hidden;
      position: relative;
      height: 400px;
      transition: transform 0.1s ease-in-out; /* 应用的过渡 */
    }
    .item:hover {
      transform: translateY(-10px);
    }
  }
}

.img_center {
  height: 285px;
  width: 100%;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.img_message {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
  .img_message_title {
    height: 24px;
    font-family: "SHS-Bold" !important;
    font-weight: 700;
    font-size: 16px;
    color: #3d3d3d;
    width: 220px;
    text-align: center;
  }
  .img_message_price {
    height: 28px;
    font-family: "D-DIN-Bold" !important;
    font-weight: 400;
    font-size: 16px;
    color: #4e5969;
  }
}
.picture {
  border-radius: 10px 10px 10px 10px;
}
</style>
